package com.zx.zxapibackend.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zx.zxapibackend.model.domain.User;
import com.zx.zxapibackend.model.dto.user.UserBindPhoneRequest;
import com.zx.zxapibackend.model.dto.user.UserLoginBySmsRequest;
import com.zx.zxapibackend.model.dto.user.UserQueryRequest;
import com.zx.zxapibackend.model.dto.user.UserRegisterRequest;
import com.zx.zxapicommon.model.to.Oauth2ResTo;
import com.zx.zxapicommon.model.vo.LoginUserVO;
import com.zx.zxapibackend.model.vo.UserVO;
import com.zx.zxapicommon.common.BaseResponse;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 用户服务
 *
 * @author 张旭
 * 
 */
public interface UserService extends IService<User> {


    /**
     * 用户登录
     *
     * @param userAccount  用户账户
     * @param userPassword 用户密码
     * @param request
     * @return 脱敏后的用户信息
     */
    LoginUserVO userLogin(String userAccount, String userPassword, HttpServletRequest request, HttpServletResponse response);


    /**
     * 获取当前登录用户
     *
     * @param request
     * @return
     */
    User getLoginUser(HttpServletRequest request);

    /**
     * 获取当前登录用户（允许未登录）
     *
     * @param request
     * @return
     */
    User getLoginUserPermitNull(HttpServletRequest request);

    /**
     * 是否为管理员
     *
     * @param request
     * @return
     */
    boolean isAdmin(HttpServletRequest request);



    /**
     * 获取脱敏的已登录用户信息
     *
     * @return
     */
    LoginUserVO getLoginUserVO(User user);

    /**
     * 获取脱敏的用户信息
     *
     * @param user
     * @return
     */
    UserVO getUserVO(User user);

    /**
     * 获取脱敏的用户信息
     *
     * @param userList
     * @return
     */
    List<UserVO> getUserVO(List<User> userList);

    /**
     * 获取查询条件
     *
     * @param userQueryRequest
     * @return
     */
    QueryWrapper<User> getQueryWrapper(UserQueryRequest userQueryRequest);

    Boolean sendCode(String phoneNum);

    BaseResponse checkUserLogin(HttpServletRequest request, HttpServletResponse response);

    void getCaptcha(HttpServletRequest request, HttpServletResponse response);

    long userRegister(UserRegisterRequest userRegisterRequest, HttpServletRequest request);

    BaseResponse<Page<UserVO>> listUserByPage(UserQueryRequest userQueryRequest);

    BaseResponse oauth2Login(Oauth2ResTo oauth2ResTo, String type, HttpServletResponse httpServletResponse);

    BaseResponse loginBySms(UserLoginBySmsRequest loginBySms, HttpServletResponse response);

    BaseResponse getGithubStars();

    BaseResponse bindPhone(UserBindPhoneRequest userBindPhoneRequest, HttpServletRequest request);

    BaseResponse updateUserPass(String password, HttpServletRequest request);

    BaseResponse authPassUserCode(String code, HttpServletRequest request);

    BaseResponse sendPassUserCode(HttpServletRequest request);

    BaseResponse getPassUserType(String username, HttpServletResponse response);

}
